package com.scuec.groupfive.service.impl;

import com.scuec.groupfive.mapper.PostFavoriteMapper;
import com.scuec.groupfive.service.PostFavoriteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;

@Service
public class PostFavoriteServiceImpl implements PostFavoriteService {
    @Autowired
    private PostFavoriteMapper postFavoriteMapper;

    @Override
    public int getTotalFavoriteCount() {
        return postFavoriteMapper.getTotalFavoriteCount();
    }

    @Override
    public int getFavoriteCountByPostId(Long postId) {
        return postFavoriteMapper.getFavoriteCountByPostId(postId);
    }

    @Override
    public int getFavoriteCountByDateRange(Date startDate, Date endDate) {
        // 结束日期设置为当天的23:59:59
        endDate = new Date(endDate.getTime() + 24 * 60 * 60 * 1000 - 1);
        return postFavoriteMapper.getFavoriteCountByDateRange(startDate, endDate);
    }
}